import { Component } from '@angular/core';

import { AlertController, App, ModalController, NavController} from 'ionic-angular';

import { DraftListService } from './list.service';

import { Config } from '../../../providers/config';

import { DraftDetailPage } from '../detail/detail.component';

import { Storage } from '@ionic/storage';

import _ from 'lodash';


@Component({
  selector: 'page-draft-list',
  templateUrl: './list.html',
  providers: [DraftListService]
})
export class DraftListPage {
	moa_page_name: any = "page-draft-list";
  moa_page_explain: any = "起草流程";

  isHiddenIPOMol = true; //是否隐藏新股IPO询价、申购选项
  drafAuthorityUsers = ["fengjk", "wulh", "zqx"];//拥有新股询价、申购权限的人员
  drafAuthorityOrgs = ["信息技术部"];//拥有新股询价、申购权限的部门列表

  constructor(
    public alertCtrl: AlertController,
    public app: App,
    public modalCtrl: ModalController,
    public navCtrl: NavController,
    public listService: DraftListService,
    public config: Config,
    public storage: Storage,
  ) {
    this.checkListAuthority();
  }
/**
 * [goDetailPage 跳转详情页]
 * @param {[type]} item [参数]
 */
  goDetailPage(type){
    this.navCtrl.push(DraftDetailPage,{type : type});
  }

  /**
 * [checkListAuthority 检查是否有查看IPO列表的权限]
 */
  checkListAuthority() {
    this.storage.get("configs").then(configs => {
      let regularMenu = _.find(configs, {name: "regularMenu"})['json'];
      let isShow = _.find(regularMenu, {id: "oa"})['showDrafList'];

      if (isShow) {
        this.isHiddenIPOMol = false;
      }

    })
  }
}
